﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Reflection;
using System.Windows;

namespace SoundServant
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    partial class App : Application
    {

        void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Logs.Error("FATAL UNHANDLED ERROR", "Sound Servant has encountered and unhandled error. It is vital that you report this error to your Sound Servant. Thank You.", e.ExceptionObject.ToString());
            Process.Start(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
            ((Process)Process.GetCurrentProcess()).Kill();
        }

        private void Application_Startup(object sender, StartupEventArgs e)
        {
            if (e.Args.Length == 0 || e.Args[0] != "DEGBUG")
            {
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            }
        }


    }
}
